<h3><?php echo $this->title?></h3>
<div class="upload-image">
<div style="color:red;" id="edit_message"><?php echo $this->errMessage;?></div>
<form action="/admin/comment/list" method="get">
    <h4>Tìm kiếm bình luận</h4>
    <table class="table table-condensed">
        <tr>
            <td><label for="id">Id:</label></td>
            <td><input type="text" id="id" name="id" value="<?php echo $this->params['id'];?>" /></td>
        </tr>
        <tr>
            <td><label for="title">Nội dung:</label></td>
            <td><input id="title" name="title" value="<?php echo $this->params['title'];?>" /></td>
            <td><label for="course_id">Khóa học</label></td>
            <td>
                <select id="course_id" name="course_id">
                    <option value="0" <?php echo 0 == $this->params['course_id']?"selected='selected'":""?>>[Tất cả]</option>
                    <?php foreach ($this->courses as $course) : ?>
                    <option value="<?php echo $course['id']?>" <?php echo $course['id'] == $this->params['course_id']?"selected='selected'":""?>><?php echo $course['titles']['vi']['content']?></option>
                    <?php endforeach;?>
                </select>
            </td>
        </tr>
    </table>
    <div class="control-group">
        <div class="controls">
          <button type="submit" class="btn">Tìm</button>
        </div>
  </div>
</form>
<?php if(is_array($this->comments)) {?>
    <table class="table table-bordered table-striped">
        <thead>
              <tr>
                <th style="width: 10%;">Tên người gửi</th>
                <th style="width: 15%;">Email</th>
                <td style="width: 15%;">Khóa học</td>
                <td style="width: 25%;">Nội dung</td>
                <td style="width: 5%;">Trạng thái</td>
                <th>Ngày gửi</th>
                <th>Ngày trả lời</th>
                <th>Thao tác</th>
              </tr>
        </thead>
        <tbody>
            <?php foreach($this->comments as $comment) :?>
             <tr>
                 <td><b><?php echo $comment['username']?></b></td>
                 <td>
                     <?php echo $comment['email']?>
                 </td>
                 <td>
                     <?php echo $comment['course_name'];?>
                 </td>
                 <td>
                     <?php echo $comment['comment']?>
                 </td>
                 <td style="text-align: center;">
                     <?php if($comment['active']) {?>
                         <a href="javascript:void(0);" data-id="<?php echo $comment['id'];?>" data-value="0" class="activateComment" title="Click vào để vô hiệu bình luận này" >
                             <i class="icon-ok"></i>
                         </a>
                     <?php } else {?>
                         <a href="javascript:void(0);" data-id="<?php echo $comment['id'];?>" data-value="1" class="activateComment" title="Click vào để duyệt bình luận này" >
                             <i class="icon-ban-circle"></i>
                         </a>
                     <?php }?>
                 </td>
                 <td>
                     <?php echo date('d-m-Y H:i:s', $comment['dateline']);?>
                 </td>
                 <td>
                     <?php echo  $comment['last_update']? date('d-m-Y H:i:s', $comment['last_update']) :"";?>
                 </td>
                 <td>
                     <a data-backdrop="static" data-toggle="modal" href="#reply_comment_popup_<?php echo $comment['id']?>" title="Trả lời bình luận này" >
                         <i class="icon-comment"></i>
                     </a>
                     <a href="/admin/comment/delete/id/<?php echo $comment['id']?>" onclick="return confirm('Thật sự muốn xóa?');" title="Xóa bình luận này">
                         <i class="icon-remove"></i>
                     </a>
                 </td>
             </tr>
             <div id="reply_comment_popup_<?php echo $comment['id']?>" class="modal fade" style="display: none;" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                    <form action="/admin/comment/edit/id/<?php echo $comment['id'];?>" onsubmit="return HandleFunction.onReplyComment('<?php echo $comment['id'];?>');">
                    <div class="modal-dialog">
                      <div class="modal-content">
                        <div class="modal-header">
                          <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                          <h4 class="modal-title">Trả lời câu hỏi</h4>
                        </div>
                        <div class="modal-body">
                            <div id="message<?php echo $comment['id']?>"></div>
                            <label for="edit_en_title">Nhập nội dung</label>
                            <textarea type="text" id="reply" name="reply" maxlength="5000" style="width: 90%; height: 100px;" row="5"><?php echo $comment['reply']?></textarea>
                        </div>
                        <div class="modal-footer">
                          <button type="button" class="btn btn-default" data-dismiss="modal">Hủy</button>
                          <input type="submit" class="btn btn-primary" value="Trả lời"/>
                        </div>
                      </div>
                    </div>
                    </form>
            </div>
             <?php endforeach;?>
        </tbody>
      </table>
      <?php echo $this->paginationcontrol2($this->page, $this->totalItem, $this->numRowPerPage, 'pagination.phtml', $this->currentUrl);?>
</div>
<?php } else {?>
<div>Không có comment nào!</div>
<?php }?>
